package com.tc.controller;

import com.tc.OrderDto.Order;
import com.tc.dto.Result;
import com.tc.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    //提交订单
    @PostMapping("/addOrder")
    public Result addOrder(@RequestBody Order order, HttpServletRequest request){
        return orderService.addOrder(order,request);
    }

    //获取用户的所有订单
    @GetMapping("/getAllOrder")
    public Result getAllOrder(HttpServletRequest request){
        return orderService.getAllOrder(request);
    }

    //删除订单
    @DeleteMapping("/deleteOrder/{orderNumber}")
    public Result deleteOrder(@RequestBody Order item,@PathVariable String orderNumber,HttpServletRequest request){
        return orderService.deleteOrder(item,orderNumber,request);
    }
}
